import unittest
import requests
from ddt import ddt, data, unpack

header = {"Content-Type": "application/json"}
cookie = {"session": "5e8b820c-9c04-43c0-9340-5509eadb291d.XtNbfRmjun8WFuB5l0K7Yr1p4mY"}


@ddt
class TestInterface(unittest.TestCase):

    # collect表示收藏，cancel_collect表示取消收藏
    @data([1, "cancel_collect"],
          [27, "collect"],
          [17, "collect"],
          [29, "collect"])
    @unpack
    def test_case1(self, news_id, action):
        data2 = ('{"news_id": "%s", "action": "%s"}' % (news_id, action)).encode("utf-8")
        r = requests.post("http://192.168.41.120:9999/news/news_collect", headers=header, cookies=cookie, data=data2)
        # print(r.json())


if __name__ == '__main__':
    unittest.main()
